<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>上传layui</title>
    <link rel="stylesheet" type="text/css" href="commons/layui/css/layui.css"/>
</head>
<body>

<!-- 你的HTML代码 -->
<button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>上传视频</button>
<script src="commons/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form', 'upload'], function () {
        var layer = layui.layer
            , form = layui.form
            , upload = layui.upload;
        upload.render({
            elem: '#test5'
            , url: 'http://localhost:2233/upload/upload'
            , accept: 'video'
            , field: 'uploadFile'
            , method: 'post'
            , done: function (res) {
                if (res.get("1") != null) {
                    console.log('success')
                }
                if (res.get("2") != null) {
                    console.log('fail')
                }
                layer.msg("over")
            }
        });
    });
</script>
</body>
</html>
